#想要获取指定贴吧中的指定页数内容
#获取北京国安贴吧 前五页
#导模块
import requests
#确定url
url = 'https://tieba.baidu.com/f'
#构造请求头
headers={'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) '
                      'AppleWebKit/537.36 (KHTML, like Gecko) '
                      'Chrome/96.0.4664.55 Safari/537.36 Edg/96.0.1054.43'}
name=input('输入吧名：')
params={
    'kw':name,
    'pn':0
}
#修改字典
for page in range(5):
    params['pn']=page*50
#发送请求
    response=requests.get(url,params=params,headers=headers)

    with open(f'{name}--{page+1}.html','wb') as file_build:
        file_build.write(response.content)

